package com.base.blocking.queue;

import java.util.concurrent.BlockingQueue;

public class Consumer implements Runnable {
    private final BlockingQueue queue;

    public Consumer(BlockingQueue queue) {
        this.queue = queue;
    }

    @Override
    public void run() {
        try {
            while (true){
                consume(queue.take());
                Thread.sleep(500);
            }

        } catch (InterruptedException ex) {
        }
    }

    void consume(Object x) {
        System.out.println("消费："+x);
    }
}
